package com.wn;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.Set;

/**
 * @author yellow Docter
 * @date 2023 -06-20
 * @desc  有能力  使用 模板操作 其他的数据类型
 *
 * redis 的其他的内容:
 * 1、持久化 (必须将) 集群搭建 (docker-compose 搭建)
 *
 * 2、分布式锁   后面将
 *
 */
@SpringBootTest
public class RedisTest04 {

    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void demo01(){

        //操作set 数据
        redisTemplate.opsForSet().add("s1","a","b","c");
        redisTemplate.opsForSet().add("s2","c");

    }

    @Test
    public void dmeo02(){

        Set difference = redisTemplate.opsForSet().difference("s1", "s2");
        System.out.println("difference = " + difference);

        Boolean member = redisTemplate.opsForSet().isMember("s1", "bc");
        System.out.println("member = " + member);

    }

    @Test
    public void dmeo03(){

//        redisTemplate.opsForList().leftPushAll("arr","a","b","c");

//        redisTemplate.opsForList().rightPush("arr","hello");
        List arr = redisTemplate.opsForList().range("arr", 0, -1);
        System.out.println("arr = " + arr);

    }
}
